﻿<script language="javascript">
	function check_password(){
		var password = $("merchant_password").value;
		var password_confirmation = $("merchant_password_confirmation").value;
		var message = "";
		if(password.length < 6){
			message = "密码的长度不可少于6位";
		}else if(password != password_confirmation){
			message = "两次输入的密码必须一致";
		}
		
		if(message != ""){
			$("password_message").update (message);
			return false;
		}else{
			return true;
		}
	}
</script>

<div class="merchant_new_wrapper">
	<div class="merchant_new_form_title">
		<div class="merchant_new_title_wrapper"><img src="/images/form_title.png"/> 注册商户</div>
	</div>
	<div class="error_info"><span class="error_info_text"><%= error_messages_for 'merchant' %></span></div>
	<% form_for :merchant, :url => {:action => "create"} do |form|%>
	<div id="merchant_new_form_content">
		<table width="100%" border="0" cellpadding="0" cellspacing="1">
			<tr>
				<td class="form_td_left"><span class="form_td_left_name">用户名</span></td>
				<td class="form_td_right">
					<span class="form_td_right_element">
						<%= form.text_field :username, :size => 20, 
                        :onblur => remote_function(:url => {:action => 'check_username'},
                                                   :loading => "Element.show('spinner')",
                                                   :loaded => "Element.hide('spinner')",
                                                   :with => "'username=' + encodeURIComponent(value)") %>
						<span id="username_message"></span>
						<%= image_tag 'indicator-small.gif', :id => 'spinner', :style => 'display:none; float:right;' %>
					</span>
				</td>
			</tr>
			<tr>
				<td class="form_td_left"><span class="form_td_left_name">密&nbsp;码</span></td>
				<td class="form_td_right">
					<span class="form_td_right_element"><%= form.password_field :password, :size =>20 %></span>
				</td>
			</tr>
			<tr>
				<td class="form_td_left"><span class="form_td_left_name">确认密码</span></td>
				<td class="form_td_right">
					<span class="form_td_right_element"><%= form.password_field :password_confirmation, :size =>20 %>
						<span id="password_message"></span>
					</span>
				</td>
			</tr>
			<tr>
				<td class="form_td_left"><span class="form_td_left_name">真&nbsp;名</span></td>
				<td class="form_td_right">
					<span class="form_td_right_element"><%= form.text_field :real_name, :size =>20 %></span>
				</td>
			</tr>
		</table>
	</div>
	<div id="merchant_new_form_button_area">
		<div class="merchant_new_form_button_wrapper">
			<%= submit_tag("注    册", :id => 'commit', :onclick => "return check_password();", :class => "merchant_new_form_button") %>
			<input class="login_form_button" type="button" name="submit" value="撤    消"/>
		</div>
	</div>
	<% end %>
</div>